#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#define __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>
#include <iostream>
#include <string>
#include <vector>
#include <ostream>
#include <stdexcept>

class clWrapper {
	std::vector<cl::Platform> platforms;

public:	

	clWrapper()
	{
		cl::Platform::get(&platforms);
	}

	clWrapper(cl::Platform &plat)
	{
		platforms.push_back(plat);
	}
	cl::Platform getPlatform()
	{
		if (platforms.size() ==1)
			return platforms[0];
		else
		{
			std::cout << "\n\nPlease enter the Platform Number to be selected: (0 to  " << platforms.size()-1 << " ):"<< std::endl;
			unsigned i;
			std::cin >> i;
			if (i >(platforms.size()-1) )
			{
				std::cerr <<" Incorrect Number entered. Exiting" ;
				system("pause");
				exit(EXIT_FAILURE);				
			}
			else
				return platforms[i];	
		}		
	}

	friend std::ostream& operator<<(std::ostream& os, const clWrapper& cl);

};

std::ostream& operator<<(std::ostream& os, const clWrapper& cl)
{
	for(std::size_t i = 0; i < cl.platforms.size(); ++i)
	{
		os<< "Platform #" << i << ":" << std::endl;
		os<< "CL_PLATFORM_VERSION\t= " << cl.platforms[i].getInfo<CL_PLATFORM_VERSION>() << std::endl;	
		os<< "CL_PLATFORM_NAME\t= " << cl.platforms[i].getInfo<CL_PLATFORM_NAME>() << std::endl;	
		os<< "CL_PLATFORM_VENDOR\t= " << cl.platforms[i].getInfo<CL_PLATFORM_VENDOR>() << std::endl;	
		os<< "CL_PLATFORM_EXTENSIONS\t= " << cl.platforms[i].getInfo<CL_PLATFORM_EXTENSIONS>() << std::endl;	
	}
	return os;
}
